﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace moveplate
{
    class Program
    {
       
        static void Main(string[] args)
        {
            Console.WriteLine("请输入盘子的个数：");
            int num = int.Parse(Console.ReadLine());
            hanoi(num,'a','b','c');
            Console.ReadKey();
        }
        /// <summary>
        /// 递归函数分三个阶段：1、前n-1通过c从a到b；2、最大盘直接移动；3、反向通过a从b到c
        /// </summary>
        /// <param name="n"></param>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="c"></param>
        static void hanoi(int n, char a, char b, char c)
        {
            if (n==1)
            {
                move(n,a, c);
            }
            else
            {
                hanoi(n - 1, a, c, b);
                move(n,a, c);
                hanoi(n - 1, b, a, c);
            }
        }
        /// <summary>
        /// 显示移动过程
        /// </summary>
        /// <param name="n"></param>
        /// <param name="a"></param>
        /// <param name="b"></param>
        static void move(int n,char a, char b)
        {
            Console.WriteLine($"move plate{n} from {a} to {b}");
        }
    }
}
